home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tex / style / misc / bnf.sty < prev    next >
Text File  |  1995-11-25  |  5KB  |  166 lines

  1. %% 
  2. %% This is file `bnf.sty', generated on <1993/2/16> 
  3. %% with the docstrip utility (2.0r).
  4. %% 
  5. %% The original source file was `bnf.doc'.
  6. %% Included options: `style'.
  7. %% 
  8. %% 
  9. %% IMPORTANT NOTICE:
  10. %% You are not allowed to distribute this file.
  11. %% For distribution of the original source see
  12. %% the copyright notice in the file bnf.doc.
  13. %% 
  14. \def\filename{BNF.DOC}
  15. \def\fileversion{1.05}
  16. \def\filedate{09 Feb 1993 15:16:48 BST}
  17. \def\docdate{09 Feb 1993 15:16:48 BST}
  18. %%% ====================================================================
  19. %%%  @LaTeX-file{
  20. %%%     filename        = "BNF.DOC",
  21. %%%     version         = "1.05",
  22. %%%     date            = "09 Feb 1993",
  23. %%%     time            = "15:16:48 BST",
  24. %%%     author          = "Mike Piff",
  25. %%%     address         = "Dr M. J. Piff
  26. %%%                        University of Sheffield
  27. %%%                        Department of Pure Mathematics
  28. %%%                        Hicks Building
  29. %%%                        Hounsfield Road
  30. %%%                        SHEFFIELD S3 7RH
  31. %%%                        England",
  32. %%%     codetable       = "ISO/ASCII",
  33. %%%     telephone       = "+44 742 824431",
  34. %%%     email           = "M.Piff@shef.ac.uk (Janet)",
  35. %%%     keywords        = "Backus,Naur,syntax,grammar",
  36. %%%     supported       = "yes",
  37. %%%     checksum        = "15432 526 2399 20401",
  38. %%%     docstring       = "A style option to LaTeX for producing
  39. %%%                        Backus-Naur Form syntax notation.",
  40. %%%  }
  41. %%% ====================================================================
  42. %% This is BNF.DOC
  43. %% Copyright (C) 1993 Mike Piff
  44. %% All rights reserved.
  45. %% Copying of this file is authorized only if
  46. %% you make absolutely no changes to your copy.
  47. %%
  48. %% Usage:
  49. %% \documentstyle[bnf]{article} %% in LaTeX
  50.  %<+driver>   \DocInput{BNF.DOC}
  51. \typeout{Backus-Naur Form style option for LaTeX, (c) Mike Piff, \filedate}
  52. \newif\ifnonterminal
  53. \def\NonTerminal{\left\langle\obeyspaces\ControlSpaces
  54.    \nonterminaltrue\NonTerminalStyle}
  55. \def\endNonTerminal{\right\rangle}
  56. \def\NonTerminalStyle{\fam0 }
  57. {\obeyspaces\gdef\ControlSpaces{\let =\ }}
  58. \def\Star{\,\left\{}  \def\endStar{\right\}\,}
  59. \def\Optional{\,\left[} \def\endOptional{\right]\,}
  60. \def\Bracket{\,\left(} \def\endBracket{\right)\,}
  61. \def\OR{\mathop{\left|\right.}\nolimits}
  62. \def\Production{\mathrel{\longrightarrow}}
  63. \def\Yields{\mathrel{\Longrightarrow}}
  64. \def\Empty{\varepsilon}
  65. \begingroup
  66.  \catcode`\`=\active
  67.  \gdef\TerminalFont{\tt \catcode96\active
  68.    \def`{\leavevmode\kern\z@\char96 }}
  69. \endgroup
  70. \begingroup
  71.   \catcode`\~=\active
  72.   \lccode`\~=`\^^M
  73.   \lowercase{\endgroup
  74.     \gdef\Terminal{\relax\PreTerminal
  75.       \ifmmode \hbox \else \leavevmode\null \fi
  76.       \bgroup
  77.       \TerminalFont
  78.       \catcode`~\active
  79.       \def~{\egroup\@latexerr{Terminal string ended by
  80.                               end of line.}\@ehc}%
  81.     \let\do\@makeother \dospecials
  82.     \@sTerminal}}
  83. \def\@sTerminal#1{%
  84.   \catcode`#1\active
  85.   \lccode`\~`#1%
  86.   \lowercase{\def~{\egroup\PostTerminal}}}%
  87. \def\PreTerminal{} \def\PostTerminal{}
  88. \mathchardef\lt="313C \mathchardef\gt="313E
  89. \def\mathactive{"8000}
  90. \def\bnf{%
  91.    \mathchardef\HYPHEN="2D  \mathchardef\MINUS="2200
  92.    \mathchardef\Relbar="303D  \def\relbar{\mathrel{\smash{\MINUS}}}
  93.    \mathchardef\EQUALS="303D
  94.    \mathcode`"=\mathactive
  95.    \mathcode`[=\mathactive \mathcode`\]=\mathactive
  96.    \mathcode`(=\mathactive \mathcode`\)=\mathactive
  97.    \mathcode`|=\mathactive \mathcode`-=\mathactive
  98.    \mathcode`<=\mathactive \mathcode`\>=\mathactive
  99.    \mathcode`@=\mathactive \mathcode`==\mathactive
  100.    \mathcode96 \mathactive
  101. }
  102. \def\endbnf{}
  103. \def\NotInNonTerminal{\errmessage{Not allowed in a non-terminal}}
  104. \def\NotNTdef#1#2{\gdef#1{\ifnonterminal\NotInNonTerminal\else#2\fi}}
  105. \begingroup
  106.    \catcode`"\active
  107.    \catcode`[\active \catcode`\]\active
  108.    \catcode`(\active \catcode`\)\active
  109.    \catcode`|\active \catcode`-\active
  110.    \catcode`<\active \catcode`>\active
  111.    \catcode`@\active \catcode`=\active
  112.    \catcode96 \active
  113.    \gdef"{\Terminal"}%
  114.    \gdef`{\Terminal`}%
  115.    \NotNTdef[\Optional        \NotNTdef]\endOptional
  116.    \NotNTdef(\Bracket         \NotNTdef)\endBracket
  117.    \NotNTdef|\OR              \NotNTdef<\NonTerminal
  118.    \gdef>{\endNonTerminal}%
  119.    \gdef-{%
  120.       \ifnonterminal
  121.          \def\Nnext{\HYPHEN}%
  122.       \else
  123.          \def\Nnext{\futurelet\Next\SeeIfProdn}%
  124.       \fi\Nnext}
  125.    \gdef={%
  126.       \ifnonterminal
  127.          \def\Nnext{\NotInNonTerminal}%
  128.       \else
  129.          \def\Nnext{\futurelet\Next\SeeIfYields}%
  130.       \fi\Nnext}%
  131.    \gdef@{% either an escape char or a star group
  132.       \ifnonterminal
  133.          \def\Nnext{\NotInNonTerminal}%
  134.       \else
  135.          \def\Nnext{\futurelet\Next\SeeIfSpecial}%
  136.       \fi\Nnext}%
  137. \endgroup
  138. \def\SeeIfProdn{%
  139.    \if\noexpand\Next\noexpand>%
  140.       \def\Nnext{\Production\@gobble}%
  141.    \else
  142.       \def\Nnext{\MINUS}%
  143.    \fi
  144.    \Nnext}
  145. \def\SeeIfYields{%
  146.    \if\noexpand\Next\noexpand>%
  147.       \def\Nnext{\Yields\@gobble}%
  148.    \else
  149.       \def\Nnext{\EQUALS}%
  150.    \fi\Nnext}
  151. \def\SeeIfSpecial{%
  152.    \if\noexpand\Next\noexpand<%
  153.       \def\Nnext{\lt\@gobble}%
  154.    \else
  155.       \if\noexpand\Next\noexpand>%
  156.          \def\Nnext{\gt\@gobble}%
  157.       \else
  158.          \def\Nnext{\Star\bgroup\aftergroup\endStar\aftergroup\egroup}%
  159.       \fi
  160.    \fi\Nnext}
  161.  
  162. \endinput
  163. %% 
  164. %% End of file `bnf.sty'.
  165.  
  166. ə